import { NzTreeNodeOptions } from 'ng-zorro-antd/tree';

import { BaseEntity } from '../../base';

export class Area extends BaseEntity {
  pcode: string;
  code: string;
  name: string;
  pathCode: string;
  isLeaf: boolean;

  constructor(o?: any) {
    super(o);
    this.pcode = o && o.pcode !== null ? o.pcode : null;
    this.code = o && o.code !== null ? o.code : null;
    this.name = o && o.name !== null ? o.name : null;
    this.pathCode = o && o.pathCode !== null ? o.pathCode : null;
    this.isLeaf = o && o.isLeaf !== null ? o.isLeaf : null;
  }

  toNzTreeNodeOptions(): NzTreeNodeOptions {
    return {
      title: this.name,
      key: this.code,
      isLeaf: this.isLeaf || true,
      area: this
    };
  }
}
